package com.d0323;

import java.io.*;

public class SerializableTest {
    public static void main(String[] args) throws Exception {
        //ByteArrayOutputStream bos = new ByteArrayOutputStream();
        FileOutputStream fos= new FileOutputStream(new File("src/com/d0323/seriData.txt"));
        ObjectOutputStream oos = new ObjectOutputStream(fos);
        Person person = new Person("laoba",18,"dalian");
        oos.writeObject(person);
       // byte[] buff=bos.toByteArray();
        oos.close();
        fos.close();
        //ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(new File("src/com/d0323/seriData.txt")));
        //ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(buff));
        //Person person1= (Person)ois.readObject();
        //System.out.println(person1);
        FileInputStream fis = new FileInputStream(new File("src/com/d0323/seriData.txt"));
        ObjectInputStream ois = new ObjectInputStream(fis);
        Person person1= (Person) ois.readObject();
        //System.out.println(person1.getName()+person1.getAge()+person1.getAddress());
        System.out.println(person1);
        ois.close();
        fis.close();
    }
}
